﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class Controls_Chitiet_Tintuc : System.Web.UI.UserControl
{
    BUS_Tintuc tintuc = new BUS_Tintuc();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string ID = Request.QueryString["ID"];
            
            //if (ID == null) Response.Redirect("Tintuc.aspx");
            if (ID == null || Chitiet_Tintuc(ID).Rows.Count <1)
            {
                Response.Write("<script language='JavaScript'> confirm('Rất tiếc! Trang này hiện không có!'); </script>");
                Response.Redirect("Tintuc.aspx");

            }
            else
            {
                Page.Title = Chitiet_Tintuc(ID).Rows[0]["Title"].ToString();
                ltrTitle.Text = Chitiet_Tintuc(ID).Rows[0]["Title"].ToString();
                rptNews.DataSource = Chitiet_Tintuc(ID);
                rptNews.DataBind();
            }
        }
    }
    public DataTable Chitiet_Tintuc(string id)
    {
        DataTable dt = new DataTable();
        dt = tintuc.Chitiet(id);
        return dt;
    }
    public string title(string ID)
    {
        DataTable dt = new DataTable();
        dt = Chitiet_Tintuc(ID);
        return dt.Rows[0]["Title"].ToString();
    }
}